/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * NewJDialogAtributosRelacion.java
 *
 * Created on 20/06/2012, 03:59:39 PM
 */
package Almacenamiento;

import javax.swing.table.DefaultTableModel;

/**
 *
 * @author AMD
 */
public class NewJDialogAtributosRelacion extends javax.swing.JDialog {
    RelacionFile rf;
    /** Creates new form NewJDialogAtributosRelacion */
    public NewJDialogAtributosRelacion(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    public NewJDialogAtributosRelacion(java.awt.Frame parent, boolean modal, RelacionFile rf) {
        super(parent, modal);
        initComponents();
        this.rf = rf;
        ColcocarAtributosEnTabla();
    }
    private void ColcocarAtributosEnTabla(){
        this.setTitle("Atributos de la relación: "+ rf.getNameRelacion());
        String [] encabezado ={"Nro","Nombre",  "Tipo Atributo"};        
        DefaultTableModel modelo = new DefaultTableModel(encabezado, 0);
        for (int i = 0; i <rf.getRelacion().getAtributos().size(); i++) {
            Object[] o = {i+1, rf.getRelacion().getAtributos().get(i).getNombre(), rf.getRelacion().getAtributos().get(i).getTipo()};                    
            modelo.addRow(o);
        }  
        table_Atributos.setModel(modelo);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        table_Atributos = new javax.swing.JTable();
        btn_Salir = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        table_Atributos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(table_Atributos);

        btn_Salir.setText("Salir");
        btn_Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_SalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 364, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(136, 136, 136)
                        .addComponent(btn_Salir, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 382, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_Salir, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SalirActionPerformed
        this.setVisible(false);
            // TODO add your handling code here:
    }//GEN-LAST:event_btn_SalirActionPerformed

    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Salir;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable table_Atributos;
    // End of variables declaration//GEN-END:variables
}
